<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新用户登录表</title>
</head>
<body>
<form>
    <table border="1">
        <tr><td colspan="2"><h1>更新用户登录表内容</h1></td></tr>
        <tr>
            <td>用户ID</td>
            <td>
                    <span id="customerId_txt"></span><input type="hidden" id="customerId" name="customerId"/>
            </td>
        </tr>
        <tr>
            <td>用户登录名</td>
            <td>
                    <input type="text" id="loginName" name="loginName"/>
            </td>
        </tr>
        <tr>
            <td>加密的密码</td>
            <td>
                    <input type="text" id="password" name="password"/>
            </td>
        </tr>
        <tr>
            <td>用户状态</td>
            <td>
                    <input type="text" id="userStats" name="userStats"/>
            </td>
        </tr>
        <tr>
            <td>最后修改时间</td>
            <td>
                    <input type="text" id="modifiedTime" name="modifiedTime"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other1" name="other1"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other2" name="other2"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" id="tijiao" value="提交"/>
                <input type="reset" value="重置"/>
            </td>
        </tr>
    </table>
</form>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    var param = location.href.substring(location.href.indexOf('?')+1);
    $.getJSON("/customerlogin/findById.json",param,function(detail){
        $("#customerId_txt").text(detail.customerId);
        $("#customerId").val(detail.customerId);
        $("#loginName").val(detail.loginName);
        $("#password").val(detail.password);
        $("#userStats").val(detail.userStats);
        $("#modifiedTime").val(detail.modifiedTime);
        $("#other1").val(detail.other1);
        $("#other2").val(detail.other2);
    });
    //点击提交按钮
    $("#tijiao").click(function(){
        if(!$("#loginName").val()){
            alert("用户登录名不能为空");
            return;
        }
        if(!$("#password").val()){
            alert("加密的密码不能为空");
            return;
        }
        if(!$("#userStats").val()){
            alert("用户状态不能为空");
            return;
        }
        if(!$("#modifiedTime").val()){
            alert("最后修改时间不能为空");
            return;
        }
        if(!$("#other1").val()){
            alert("其他不能为空");
            return;
        }
        if(!$("#other2").val()){
            alert("其他不能为空");
            return;
        }
        
        $.post("/customerlogin/update.json",$("form").serialize(),function(result){
            if(result.flag==true){
                alert(result.msg);
                location.href="/admin/customerlogin/list.html";
            }else{
                alert(result.msg);
            }
        })

    })
</script>

</body>
</html>